package com.ruoyi.web.controller.system;


import com.ruoyi.web.service.C2ResourceDetailUploadService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("/api/upload-excel")
public class C2ResourceDetailUploadController {

    @PostMapping("/cnid")
    public String uploadCnidResourceExcel(@RequestParam("file") MultipartFile file) {
        try {
            excelService.uploadCnidResource(file);
            return "{\"success\": true}";
        } catch (Exception e) {
            e.printStackTrace();
            return "{\"success\": false, \"message\": \"" + e.getMessage() + "\"}";
        }
    }

    @PostMapping("/apa")
    public String uploadApaResourceExcel(@RequestParam("file") MultipartFile file) {
        try {
            excelService.uploadApaResource(file);
            return "{\"success\": true}";
        } catch (Exception e) {
            e.printStackTrace();
            return "{\"success\": false, \"message\": \"" + e.getMessage() + "\"}";
        }
    }

    @Autowired
    private C2ResourceDetailUploadService excelService;
}
